class shopItem extends BaseComp {
	private shop_di:eui.Image;
	private img_icon:eui.Image;
	private img_mask:eui.Image;
	private receive_di:eui.Image;
	private lb_money:eui.Label;
	private price_di:eui.Image;
	private lb_price:eui.Label;
	private lb_shouyi:eui.Label;
	public constructor() {
		super();
	}
	
	public init()
	{

	}

	public initUI(data)
	{
		this.data = data;
		this.visible = true;
		this.img_icon.source = this.data.tujianicon;

		if(this.data['isLocked'])
		{
			this.addMask();
			this.lb_money.textColor = 0xa3a3a3;
			this.lb_price.textColor = 0x4B4B4A;
			this.receive_di.source = 'shop_4_png';
			this.price_di.source = 'shop_2_png';
			this.lb_money.text = '???';
			this.lb_price.text = '? ? ?';
		}
		else
		{
			this.img_mask.visible = false;
			this.lb_money.textColor = 0xFFFFFF;
			this.lb_price.textColor = 0xFFCA30;
			this.img_mask.mask = null;
			this.lb_price.text = this.data.price * GameConst.BuyFishMul+'';
			this.lb_money.text = 2 * this.data.price + ' / 小时';
			this.receive_di.source = 'shop_3_png';
			this.price_di.source = 'shop_1_png';
		}
	}

	//增加遮罩
	public addMask()
	{
		this.img_mask.visible = true;
		this.img_mask.mask = this.img_icon;
	}

	public addEvent()
	{
		this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.buyFish, this);
	}

	protected buyFish()
	{
		let my_money = RoleCache.instance().getGoldLb();
		let fishMax = RoleCache.instance().fishpondCnt;
		if(this.data.isLocked)
		{
			MessageUtil.tips('尚未解锁'!);
			return;
		}
		if(my_money < this.data.price)
		{
			MessageUtil.tips('金钱不足');
		}
		else
		{
			let logic:FishPoolsUI = UIManager.instance().getLogicByName(UIConst.FISH_POOLS) as FishPoolsUI;
			if(logic)
			{
				if(logic.getCurFishNum() >= fishMax)
				{
					MessageUtil.tips('鱼塘容量已达到上限');
				}
				else
				{
					FishPoolsPrase.instance().buyFish(this.data, logic.addFishToPool, logic);
				}
			}
		}
	}

	public removeEvent()
	{

	}

	public clear()
	{
		super.clear();
	}
}

window['shopItem'] = shopItem;